/** \file
 * \brief iupcb control. Table for error difusion dither.
 *
 * See Copyright Notice in iup.h
 * $Id: icb_tabs.h,v 1.2 2003/06/16 20:18:48 scuri Exp $
 */
 
#ifndef __ICB_TABS_H 
#define __ICB_TABS_H

#ifdef __cplusplus
extern "C" {
#endif

/************************************************************\
* Implementa dithering error difusion com uma palhera fixa   *
* de 216 cores.                                              *
\************************************************************/

/************************************************************\
* Mapas de conversao.                                        *
\************************************************************/
/* trunca um unsigned char [0, 255] para o valor mais proximo
entre 6 valores possiveis */
static unsigned char trc6[] =
{
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
   51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,102,102,102,102,
  102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,
  102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,
  102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,102,
  153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
  153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
  153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
  153,153,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
  204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
  204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,
  204,204,204,204,204,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
};

/* trunca um unsigned char [0, 255] para o valor mais proximo
entre 5 valores possiveis */
static unsigned char trc5[] =
{
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
   64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
   64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
   64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
   64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
  127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,
  127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,
  127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,
  127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,
  192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
  192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
  192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
  192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
};

/* converte uma componente r em [0, 255] para sua contribuiccao
no indice da palheta (abre espacco para as cores do usuario) */
static unsigned char rb6[] =
{
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  3,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
  4,  4,  4,  4,  4,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5
};

/* converte uma componente r em [0, 255] para sua contribuiccao
no indice da palheta (abre espacco para as cores do usuario) */
static unsigned char rb5[] =
{
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,
  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4
};

/* converte uma componente g em [0, 255] para sua contribuiccao
no indice da palheta */
static unsigned char gb6[] =
{
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  6,  6,  6,  6,  6,  6,
  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,
  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6,  6, 12, 12, 12, 12,
 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
 18, 18, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
 24, 24, 24, 24, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
};

/* converte uma componente g em [0, 255] para sua contribuiccao
no indice da palheta */
static unsigned char gb5[] =
{
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
};

/* converte uma componente b em [0, 255] para sua contribuiccao
no indice da palheta */
static unsigned char bb6[] =
{
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 36, 36, 36, 36, 36, 36,
 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 72, 72, 72, 72,
 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,108,
108,108,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
144,144,144,144,144,180,180,180,180,180,180,180,180,180,180,180,
180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180
};

/* converte uma componente b em [0, 255] para sua contribuiccao
no indice da palheta */
static unsigned char bb5[] =
{
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,
100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100
};


/* palheta fixa de 216 cores + 4 cores para o usuario */
static long int pal6[] =  
{
0x000000,0x330000,0x660000,0x990000,0xcc0000,0xff0000,0x003300,0x333300,
0x663300,0x993300,0xcc3300,0xff3300,0x006600,0x336600,0x666600,0x996600,
0xcc6600,0xff6600,0x009900,0x339900,0x669900,0x999900,0xcc9900,0xff9900,
0x00cc00,0x33cc00,0x66cc00,0x99cc00,0xcccc00,0xffcc00,0x00ff00,0x33ff00,
0x66ff00,0x99ff00,0xccff00,0xffff00,0x000033,0x330033,0x660033,0x990033,
0xcc0033,0xff0033,0x003333,0x333333,0x663333,0x993333,0xcc3333,0xff3333,
0x006633,0x336633,0x666633,0x996633,0xcc6633,0xff6633,0x009933,0x339933,
0x669933,0x999933,0xcc9933,0xff9933,0x00cc33,0x33cc33,0x66cc33,0x99cc33,
0xcccc33,0xffcc33,0x00ff33,0x33ff33,0x66ff33,0x99ff33,0xccff33,0xffff33,
0x000066,0x330066,0x660066,0x990066,0xcc0066,0xff0066,0x003366,0x333366,
0x663366,0x993366,0xcc3366,0xff3366,0x006666,0x336666,0x666666,0x996666,
0xcc6666,0xff6666,0x009966,0x339966,0x669966,0x999966,0xcc9966,0xff9966,
0x00cc66,0x33cc66,0x66cc66,0x99cc66,0xcccc66,0xffcc66,0x00ff66,0x33ff66,
0x66ff66,0x99ff66,0xccff66,0xffff66,0x000099,0x330099,0x660099,0x990099,
0xcc0099,0xff0099,0x003399,0x333399,0x663399,0x993399,0xcc3399,0xff3399,
0x006699,0x336699,0x666699,0x996699,0xcc6699,0xff6699,0x009999,0x339999,
0x669999,0x999999,0xcc9999,0xff9999,0x00cc99,0x33cc99,0x66cc99,0x99cc99,
0xcccc99,0xffcc99,0x00ff99,0x33ff99,0x66ff99,0x99ff99,0xccff99,0xffff99,
0x0000cc,0x3300cc,0x6600cc,0x9900cc,0xcc00cc,0xff00cc,0x0033cc,0x3333cc,
0x6633cc,0x9933cc,0xcc33cc,0xff33cc,0x0066cc,0x3366cc,0x6666cc,0x9966cc,
0xcc66cc,0xff66cc,0x0099cc,0x3399cc,0x6699cc,0x9999cc,0xcc99cc,0xff99cc,
0x00cccc,0x33cccc,0x66cccc,0x99cccc,0xcccccc,0xffcccc,0x00ffcc,0x33ffcc,
0x66ffcc,0x99ffcc,0xccffcc,0xffffcc,0x0000ff,0x3300ff,0x6600ff,0x9900ff,
0xcc00ff,0xff00ff,0x0033ff,0x3333ff,0x6633ff,0x9933ff,0xcc33ff,0xff33ff,
0x0066ff,0x3366ff,0x6666ff,0x9966ff,0xcc66ff,0xff66ff,0x0099ff,0x3399ff,
0x6699ff,0x9999ff,0xcc99ff,0xff99ff,0x00ccff,0x33ccff,0x66ccff,0x99ccff,
0xccccff,0xffccff,0x00ffff,0x33ffff,0x66ffff,0x99ffff,0xccffff,0xffffff,
0x000000,0x000000,0x000000,0x000000
};

/* palheta fixa de 125 cores + 4 cores para o usuario */
static long int pal5[] =  
{
0x000000,0x400000,0x7f0000,0xc00000,0xff0000,0x004000,0x404000,0x7f4000,
0xc04000,0xff4000,0x007f00,0x407f00,0x7f7f00,0xc07f00,0xff7f00,0x00c000,
0x40c000,0x7fc000,0xc0c000,0xffc000,0x00ff00,0x40ff00,0x7fff00,0xc0ff00,
0xffff00,0x000040,0x400040,0x7f0040,0xc00040,0xff0040,0x004040,0x404040,
0x7f4040,0xc04040,0xff4040,0x007f40,0x407f40,0x7f7f40,0xc07f40,0xff7f40,
0x00c040,0x40c040,0x7fc040,0xc0c040,0xffc040,0x00ff40,0x40ff40,0x7fff40,
0xc0ff40,0xffff40,0x00007f,0x40007f,0x7f007f,0xc0007f,0xff007f,0x00407f,
0x40407f,0x7f407f,0xc0407f,0xff407f,0x007f7f,0x407f7f,0x7f7f7f,0xc07f7f,
0xff7f7f,0x00c07f,0x40c07f,0x7fc07f,0xc0c07f,0xffc07f,0x00ff7f,0x40ff7f,
0x7fff7f,0xc0ff7f,0xffff7f,0x0000c0,0x4000c0,0x7f00c0,0xc000c0,0xff00c0,
0x0040c0,0x4040c0,0x7f40c0,0xc040c0,0xff40c0,0x007fc0,0x407fc0,0x7f7fc0,
0xc07fc0,0xff7fc0,0x00c0c0,0x40c0c0,0x7fc0c0,0xc0c0c0,0xffc0c0,0x00ffc0,
0x40ffc0,0x7fffc0,0xc0ffc0,0xffffc0,0x0000ff,0x4000ff,0x7f00ff,0xc000ff,
0xff00ff,0x0040ff,0x4040ff,0x7f40ff,0xc040ff,0xff40ff,0x007fff,0x407fff,
0x7f7fff,0xc07fff,0xff7fff,0x00c0ff,0x40c0ff,0x7fc0ff,0xc0c0ff,0xffc0ff,
0x00ffff,0x40ffff,0x7fffff,0xc0ffff,0xffffff,0x000000,0x000000,0x000000,
0x000000
};

#ifdef __cplusplus
}
#endif

#endif
